//
//  OutSickerViewModel.m
//  HonlivApp
//
//  Created by admin on 2017/6/25.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "OutSickerViewModel.h"
#import "SickInfoModel.h"
#import "SickInfoFrame.h"
@interface OutSickerViewModel ()

@property (nonatomic,strong) NSDictionary *dic;

@end
@implementation OutSickerViewModel

-(instancetype)initWithType:(OutSickerType)type date:(NSString *)date doctor:(NSString *)doctor department:(NSString *)depart page:(NSInteger)page{
    //{db:"OracleString",SqlNo:"20",就诊日期:"2017-04-20",医生工号:"0025",Page:"1"}
    //{db:"OracleString",SqlNo:"23",就诊日期:"2017-04-15",科室编码:"010512",医生工号:"0025",Page:"1"}
    NSString *pageNum = [NSString stringWithFormat:@"%ld",page];
    if (type == OutSickerTypePersonal) {
        _dic = @{@"db":@"OracleString",@"SqlNo":@"20",@"就诊日期":date,@"医生工号":@"0025",@"Page":pageNum};
    }else{
        _dic = @{@"db":@"OracleString",@"SqlNo":@"23",@"就诊日期":date,@"科室编码":@"010512",@"医生工号":@"0025",@"Page":pageNum};
    }
    return [self init];
}

-(void)getOutSickerInfoSuccess:(void (^)(NSArray *))completion{
    NSString *url = [NSString stringWithFormat:@"%@%@",HOSPITAL_URL,COMMON_URL];
    [NetWorker getCommonDatasWithURLStr:url body:self.dic success:^(id result) {
        NSArray *arr = [JsonHelper arrayWithJsonString:result[@"Entity"]];
        NSMutableArray *modelArr = [NSMutableArray array];
        for (NSDictionary *dic in arr) {
            SickInfoModel *model = [SickInfoModel yy_modelWithDictionary:dic];
            SickInfoFrame *sickF = [[SickInfoFrame alloc] init];
            sickF.sickInfo = model;
            [modelArr addObject:sickF];
        }
        completion(modelArr);
    } failure:^(id result) {
        completion([NSArray array]);
    }];

}


@end
